#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
void mysys(char *command)
{
	pid_t pid;
	int status;
	char *word[10];
	char *temp;
	char buffer[100];
	strcpy(buffer,command);
	int num=1;
	temp=strtok(buffer," ");
	word[0]=temp;
	while(temp!=NULL)
	{
		temp=strtok(NULL," ");
		word[num]=temp;
		num++;
	}
	word[num]=NULL;
	pid=fork();
	if(pid==-1)
	{
		perror("can not open a procedure!");
	}
	else if(pid==0)
	{
		execvp(word[0],word);
	}
	else
	{
		//wait for the son procedure over
		wait(NULL);
	}
}
					

int main()
{
	printf("-------------------------------------------\n");
	mysys("echo HELLO WORLD");
	printf("-------------------------------------------\n");
	mysys("ls /");
	printf("-------------------------------------------\n");
	return 0;
}
